# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: equation_test.py
Author: kij
Create Date: 2021/2/16
-------------------------------------------------
"""
# 推导是练习

# v = [i for i in range(1, 101) if i % 2 == 0]
# print("推导是打印出100以内所有的偶数{}".format(v))
# for i in range(1, 10):
# 	for j in range(1, i + 1):
# 		print("{}*{}".format(i, j), end=" ")
# 	print()
# print("\n".join([" ".join(["{}*{}".format(i, j) for j in range(1, i + 1)]) for i in range(1, 10)]))


# v = [lambda: x for x in range(10)]  # 定义时候x位10
# print(v)  # 方法10个
# print(v[0])  # 第一个方法
# print(v[0]())  #

# data = [lambda x:x*i for i in range(10)]
# print(data)
# print(data[0](2))
# print(data[0](2) == data[8](2))

# # 请用列表推导式实现，踢出列表中的字符串，最终生成一个新的列表保存。
# data_list = [11, 22, 33, "alex", 455, 'eirc']
#
# new_data_list = [i for i in data_list if type(i)==int]  # 请在[]中补充代码实现。
# print(new_data_list)
# # 提示：可以用type判断类型

# 请用列表推导式实现，对data_list中的每个元素判断，如果是字符串类型，则计算长度作为元素放在新列表的元素中；
# 如果是整型，则让其值+100 作为元素放在新的列表的元素中。
# data_list = [11,22,33,"alex",455,'eirc']
#
# new_data_list = [len(i) if type(i) == str else i+100 for i in data_list ]  # 请在[]中补充代码实现。
# print(new_data_list)
# # 提示：可以基于三元运算实现

# data_list = [
#     (1,'alex',19),
#     (2,'老男',84),
#     (3,'老女',73)
# ]
#
# # 请使用推导式将data_list构造生如下格式：
# """
# info_dict = {
#     1:(1,'alex',19),
#     2:(2,'老男',84),
#     3:(3,'老女',73)
# }
# """
# new_dict = {}
# for i in range(len(data_list)):
# 	new_dict.update({i+1:data_list[i]})
#
# print(new_dict)
#
# print({i+1:data_list[i] for i in range(len(data_list))})
# print({i[0]:i for i in data_list})


# player = {
# 	"武沛齐": ["红桃", 10],
# 	"alex": ["红桃", 8],
# 	'eric': ["黑桃", 3],
# 	'killy': ["梅花", 12],
# }
#
#
# # player.items()相当于一个元组 然后得到数据('武沛齐', ['红桃', 10])
# new_data = sorted(player.items(),key=lambda x:x[1][1])
# print(new_data[-1][0])

# def fib(max_count):
# 	first = 1
# 	second = 0
# 	count = 0
# 	while count<max_count:
# 		next_value = first+second
# 		first = second
# 		second= next_value
# 		yield  next_value
# 		count+=1
#
#
# limit_count = input("输入斐波那契额数列:")
# limit_count = int(limit_count)
# fib_generator = fib(limit_count)
# for num in fib_generator:
# 	print(num)
v = [lambda: x for x in range(10)]
print(v)  # 10方法
print(v[0])  # 1方法
print(v[0]())  # 9
